/**
 * 
 */
package com.wbcs.system.component.application.report;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.poi.ss.usermodel.Workbook;

import com.jf.json.JbsfJsonFactory;
import com.wbcs.config.Config;
import com.wbcs.config.component.IComponentConfigBean;
import com.wbcs.config.component.application.report.ColBean;
import com.wbcs.config.component.other.JavascriptFileBean;
import com.wbcs.system.ReportRequest;
import com.wbcs.system.component.application.report.abstractreport.AbsReportType;
import com.wbcs.system.component.container.AbsContainerType;
import com.wbcs.util.Tools;

/**
 * @author hawkfly
 *
 */
public class TreeReportType extends AbsReportType {
	
	private AbsContainerType parentContainerType;
	private IComponentConfigBean reportBean;
	private ReportRequest rrquest;
	
	public TreeReportType(AbsContainerType parentContainerType,
			IComponentConfigBean comCfgBean, ReportRequest rrequest) {
		super(parentContainerType, comCfgBean, rrequest);
		// TODO Auto-generated constructor stub
		this.parentContainerType = parentContainerType;
		this.reportBean = comCfgBean;
		this.rrequest = rrequest;
	}

	/* (non-Javadoc)
	 * @see com.wbcs.system.component.application.report.abstractreport.IReportType#showReportData()
	 */
	@Override
	public String showReportData() {
		// TODO Auto-generated method stub
		//ReportBean rbean = (ReportBean)reportBean;
		//lstReportData
		//int[] aryrow = getDisplayRowInfo();
		//List<ColBean> lstColBeans=rbean.getDbean().getLstCols();
		//cbean.getDisplayValue(rowDataObjTmp,rrequest);
		/*for (int i = 0; i < lstReportData.size(); i++) {
			//数据集合转json
			Object rowData = lstReportData.get(i);
			//【显示和数据同时加载】抽取显示模板，将json数据放入并初始化模板变量
		}*/
		StringBuilder sb = new StringBuilder();
		String content=Config.getInstance().getResourceString(null,null,"${tree.content.default}",false);
		String jsonstr = JbsfJsonFactory.me().getJson().toJson(lstReportData);
		content = Tools.replaceAll(content, "%jsonstr%", jsonstr);
		content = Tools.replaceAll(content, "%pageid%", reportBean.getPageBean().getId());
		content = Tools.replaceAll(content, "%reportid%", reportBean.getId());
		content = Tools.replaceAll(content, "%WEBROOT%", Config.webroot);
		sb.append(content);
		
		JavascriptFileBean ztcorejs = new JavascriptFileBean(Config.webroot+"webresources/component/ztree/js/jquery.ztree.core-3.5.min.js", 0); 
		JavascriptFileBean ztexcheckjs = new JavascriptFileBean(Config.webroot+"webresources/component/ztree/js/jquery.ztree.excheck-3.5.min.js", 0); 
		JavascriptFileBean ztexeditjs = new JavascriptFileBean(Config.webroot+"webresources/component/ztree/js/jquery.ztree.exedit-3.5.min.js", 0);
		JavascriptFileBean wztjs = new JavascriptFileBean(Config.webroot+"webresources/component/ztree/wztree.js", 0);
		List<JavascriptFileBean> lstjsfile = new ArrayList<JavascriptFileBean>();
		lstjsfile.add(ztcorejs); lstjsfile.add(ztexcheckjs); lstjsfile.add(ztexeditjs); lstjsfile.add(wztjs);
		this.getReportRequest().getPageObj().addDynJsFileBeans(lstjsfile);
		
		List<String> cssfile = new ArrayList<String>();
		cssfile.add(Config.webroot+"webresources/css/ztree/zTreeStyle/zTreeStyle.css");
		this.getReportRequest().getPageObj().addDynCsses(cssfile);
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.wbcs.system.component.application.report.abstractreport.AbsReportType#getColSelectedMetadata()
	 */
	@Override
	public String getColSelectedMetadata() {
		// TODO Auto-generated method stub
		return "";
	}

	/* (non-Javadoc)
	 * @see com.wbcs.system.component.application.report.abstractreport.AbsReportType#showReportOnPlainExcel(org.apache.poi.ss.usermodel.Workbook)
	 */
	@Override
	public void showReportOnPlainExcel(Workbook workbook) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see com.wbcs.system.component.application.report.abstractreport.AbsReportType#showReportOnPdfWithoutTpl()
	 */
	@Override
	protected void showReportOnPdfWithoutTpl() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see com.wbcs.system.component.application.report.abstractreport.AbsReportType#getTotalColCount()
	 */
	@Override
	protected int getTotalColCount() {
		// TODO Auto-generated method stub
		List<ColBean> lstColBeans=rbean.getDbean().getLstCols();
        int cnt=0;
        for(ColBean cbean:lstColBeans)
        {
            if(cacheDataBean.getColDisplayModeAfterAuthorize(cbean)<=0) continue;
            if(cbean.isControlCol()) continue;
            cnt++;
        }
        return cnt;
	}

	/* (non-Javadoc)
	 * @see com.wbcs.system.component.application.report.abstractreport.AbsReportType#getDefaultNavigateKey()
	 */
	@Override
	protected String getDefaultNavigateKey() {
		// TODO Auto-generated method stub
		return "";
	}

}
